<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>111</li>
        <li>222</li>
    </ul>
    <script>
        var lis = document.querySelectorAll("li");
        var arr = ["张三", 20];
        for (var key in [...lis]) {
            (function (key) {
                var value = arr[key];
                // console.log(value);
                lis[key].onclick = function () {
                    console.log(value);  // 异步获取value的值；
                }
            })(key)

        }

        // {
        //     let a = 20;
        //     console.log(a);
        // }
        





    </script>
</body>

</html>